﻿// <copyright file="IcmpType.cs" company="Beuth Hochschule für Technik">
// Breakdown - Configure your Windows 7 Firewall
// Copyright (C) 2009 Stefan "dersteps@gmail.com" Matyba
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; 
// either version 3 of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.
// </copyright>
// <author>Stefan Matyba</author>
// <email>dersteps@gmail.com</email>
// <date>2009-10-18</date>
// <summary>Application logic part: Firewall rule Icmp Type wrapper class</summary>

namespace Breakdown.Logic
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// Defining an ICMP Type.
    /// </summary>
    public class IcmpType
    {
        /// <summary>
        /// The value for ICMP code ANY
        /// </summary>
        private const int ICMPCODEANY = 666;

        /// <summary>
        /// The ICMP message type
        /// </summary>
        private int _type;

        /// <summary>
        /// The ICMP message code. Set to 666 for any!
        /// </summary>
        private int _code;

        /// <summary>
        /// Initializes a new instance of the IcmpType class
        /// </summary>
        /// <param name="type">The ICMP message type</param>
        /// <param name="code">The ICMP message code</param>
        public IcmpType(int type, int code)
        {
            this._type = type;
            this._code = code;
        }

        /// <summary>
        /// Initializes a new instance of the IcmpType class (type 0, code ANY)
        /// </summary>
        public IcmpType()
            : this(0, ICMPCODEANY)
        {
            // Default constructor
        }

        /// <summary>
        /// Gets the "All ICMP Types" ICMP Type
        /// </summary>
        public static IcmpType AllICMPTypes
        {
            get
            {
                return new IcmpType(-1, -1);
            }
        }

        /// <summary>
        /// Gets or sets the MessageType (0..255)
        /// </summary>
        public int MessageType
        {
            get { return this._type; }
            set { this._type = value; }
        }

        /// <summary>
        /// Gets or sets the MessageCode (0..255)
        /// </summary>
        public int MessageCode
        {
            get { return this._code; }
            set { this._code = value; }
        }
    }
}
